package com.lengxf.design;

import java.util.stream.IntStream;

public class Client {


    public static void main(String[] args) {
        LoadBalancer l1, l2, l3, l4;
        l1 = LoadBalancer.getLoadBalancer();
        l2 = LoadBalancer.getLoadBalancer();
        l3 = LoadBalancer.getLoadBalancer();

        if (l1 == l2 && l2 == l3) {
            System.out.println("LoadBalancer 唯一 >>>>>>");
        }

        l1.addServer("Server 1");
        l1.addServer("Server 2");
        l1.addServer("Server 3");
        l1.addServer("Server 4");

        IntStream.range(0, 100).forEach(e -> {
            String server = l1.getServer();
            System.out.println("分发请求至服务器: " + server);
        });
    }
}
